package com.mydomain.Bodega;

import com.mydomain.Bodega.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("invEgresoList")
public class InvEgresoList extends EntityQuery<InvEgreso> {

	private String EJBQL = "select invEgreso from InvEgreso invEgreso join  invEgreso.invCliente c ";

	private static final String[] RESTRICTIONS = {
			" lower(invEgreso.egrObservacion) like concat(lower(#{invEgresoList.invEgreso.egrObservacion}),'%')",
			" lower(invEgreso.egrTipoPago) like concat(lower(#{invEgresoList.invEgreso.egrTipoPago}),'%')",
		 	"  cast(invEgreso.egrCodigo as string) like concat(lower(#{invEgresoList.invEgreso.buscadorEgrCodigo}),'%') ",		
		 	"  cast(c.cliCodigo as string) like concat(lower(#{invEgresoList.invEgreso.buscadorProveedor}),'%') ",
	
	};

	private InvEgreso invEgreso = new InvEgreso();

	public InvEgresoList() {
		Subdepartamento usuario = (Subdepartamento) getSessionContext().get(
				"usuarioLogeo");
		EJBQL = EJBQL
				+ " join  invEgreso.subdepartamento s  where invEgreso.depCodigo="
				+ usuario.getDepartamento().getDepCodigo()
				+ " and s.subdepCodigo=" + usuario.getSubdepCodigo();
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}

	public InvEgreso getInvEgreso() {
		return invEgreso;
	}
}
